#include <QtGui>

#include "renderarea.h"
#include "window.h"

Window::Window()
{
    renderArea = new RenderArea();

    stepSpinBox = new QSpinBox;
    stepSpinBox->setRange(0, 12);

    stepLabel = new QLabel(tr("&Step:"));
    stepLabel->setBuddy(stepSpinBox);
    
    lengthValue = new QLabel();
    lengthValue->setNum(-1);

    lengthLabel = new QLabel(tr("&Length"));
    lengthLabel->setBuddy(lengthValue);
    
    quitButton = new QPushButton(tr("&Quit"));
    connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));

    connect(stepSpinBox, SIGNAL(valueChanged(int)),
            renderArea, SLOT(setStep(int)));
    connect(renderArea, SIGNAL(lengthChanged(double)),
            lengthValue, SLOT(setNum(double)));

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setColumnStretch(3, 10);
    mainLayout->setHorizontalSpacing(20);
    mainLayout->addWidget(renderArea, 0, 0, 1, 5);
    mainLayout->addWidget(stepLabel, 1, 0);
    mainLayout->addWidget(stepSpinBox, 1, 1);
    mainLayout->addWidget(lengthLabel, 1, 2);
    mainLayout->addWidget(lengthValue, 1, 3);
    mainLayout->addWidget(quitButton, 1, 4);
    setLayout(mainLayout);

    stepSpinBox->setValue(2);

    setWindowTitle(tr("Devil's staircase"));
}
